#include "../h/CCanvas.h"
#include "../h/CPixMap.h"
#include "../h/libs/gl/axgl.h"

CCanvas::CCanvas()
{
    //ctor
}

CCanvas::~CCanvas()
{
    //dtor
}

void CCanvas::Clear()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void CCanvas::ClearColor(unsigned char red,unsigned char green,unsigned char blue)
{
    glClearColor(static_cast<float>(red) / 255.0f
    ,static_cast<float>(green) / 255.0f
    ,static_cast<float>(blue) / 255.0f
    ,1.0f);

}
void CCanvas::ClearColor(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
{
    glClearColor(static_cast<float>(red) / 255.0f
    ,static_cast<float>(green) / 255.0f
    ,static_cast<float>(blue) / 255.0f
    ,static_cast<float>(alpha) / 255.0f);
}
void CCanvas::Color(unsigned char red,unsigned char green,unsigned char blue)
{
    glColor3ub(red,green,blue);
}
void CCanvas::Color(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
{
    glColor4ub(red,green,blue,alpha);
}
void CCanvas::BlendMode(axelynx::BlendMode bm)
{
    curblend_ = bm;

}
axelynx::BlendMode CCanvas::GetCurrentBlend()
{
    return curblend_;
}

axelynx::PixMap* CCanvas::ToPixMap()
{
    axelynx::PixMap *p = new CPixMap();

    return p;
}


void CCanvas::Line(int x1,int y1, int x2, int y2)
{
    glBegin(GL_LINES);
    glVertex2i(x1,y1);
    glVertex2i(x2,y2);
    glEnd();
}
void CCanvas::ThikLine(int x1,int y1, int x2, int y2,int width)
{
    glBegin(GL_LINES);
    glVertex2i(x1,y1);
    glVertex2i(x2,y2);
    glEnd();
}

void CCanvas::Plot(int x, int y)
{
    glBegin(GL_LINES);
    glVertex2i(x,y);
    glVertex2i(x,y);
    glEnd();
}
void CCanvas::Plot(int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
    glBegin(GL_LINES);
    glVertex2i(x,y);
    glVertex2i(x,y);
    glEnd();
}

void CCanvas::Rect(int left,int top,int width,int height)
{
    glRecti(left,top,left+width,top+height);
}
void CCanvas::Oval(int x,int y, int vradius, int hradius)
{
    glRecti(x,y,x+vradius,y+hradius);
}
void CCanvas::VoidRect(int left,int top,int width,int height)
{
    glRecti(left,top,left+width,top+height);
}
void CCanvas::VoidOval(int x,int y, int vradius, int hradius)
{
    glRecti(x,y,x+vradius,y+hradius);

}
